<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css"></style>
</head>
<body>
<button onclick="zhNext()">汉文</button>
<button onclick="enNext()">英文</button>

<script type="text/javascript">
    var arrEn = ['excuse', 'me', 'yes', 'is', 'this', 'your', 'handbag', 'pardon', 'it', 'thank you', 'very much', 'pen', 'pencil'
        , 'book', 'watch', 'coat', 'dress'];
    var arrZh = ['原谅', '我(宾格)', '是的', 'be动词现在时第三人称单数', '这', '你的，你们的', '(女用)手提包', '原谅，请再说一遍', '它'
        , '感谢你（们）', '非常地', '钢笔', '铅笔', '书', '手表', '外套，上衣', '连衣裙'];

    function getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min)) + min; //不含最大值，含最小值
    }

    var temp;

    function enNext() {
        var index = getRandomInt(0, arrEn.length);
        temp = arrEn[index];
        alert(arrEn[index]);
    }

    function zhNext() {
        var index = getRandomInt(0, arrZh.length);
        temp = arrZh[index];
        alert(arrZh[index]);
    }

    document.onkeydown = function (ev) {
        if (ev.keyCode === 32) {
            if (arrEn.includes(temp)) {
                enNext();
            } else {
                zhNext();
            }
        }
    }
</script>
</body>
</html>
